package com.fc.mall.decoration.page.rs;

import com.fc.mall.base.object.Result;
import com.fc.mall.decoration.page.model.CustomPage;
import com.fc.mall.decoration.page.object.PublicCustomPageInfo;
import com.fc.mall.decoration.page.service.CustomPageService;
import io.swagger.annotations.ApiOperation;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/page")
public class PublicCustomPageResource {
    @Autowired
    CustomPageService customPageService;

    @Autowired
    MapperFacade mapperFacade;

    @ApiOperation("获取首页面")
    @GetMapping("/home")
    public Result getHomePageInfo() {
        CustomPage homePage = customPageService.getMainPage();
        PublicCustomPageInfo homePageInfo = mapperFacade.map(homePage, PublicCustomPageInfo.class);
        return Result.success(homePageInfo);
    }
}
